package com.my.company.user.service.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.my.company.base.dao.BaseDao;
import com.my.company.base.service.impl.BaseServiceImpl;
import com.my.company.user.pojo.User;
import com.my.company.user.service.UserService;

@Service("userService")
public class UserServiceImpl extends BaseServiceImpl<User> implements UserService{

	
	@SuppressWarnings("rawtypes")
	@Override
	@Resource(name="userDao")
	public void setDao(BaseDao dao) {
		super.setDao(dao);
	}

	public Integer getMaxUserId() {
		String hql="from User where 1=?";
		List<User> u=super.findEntityByHQL(hql, 1);
		int max=0;
		for(User uu:u){
			if(max<uu.getUserId()){
				max=uu.getUserId();
			}
		}
		return max;
	}

	public List<User> getAll() {
		String hql="from User where 1=?";
		return super.findEntityByHQL(hql, 1);
	}

	public List<User> getAllByCondition(String condition) {
		String hql="from User u where u.userName=? or u.dempName=? or empName=?";
		return super.findEntityByHQL(hql, condition,condition,condition);
		
	}

	

}
